package components
{
	
	import flash.events.MouseEvent;
	
	import mx.controls.Label;
	
	import nl.wv.extenders.panel.SuperPanel;
	
	import tools.*;
	
	public class AdminPanel{
		private var panel:SuperPanel = new SuperPanel();
		private var labelStudents:Label = new Label();
		private var labelAddStudents:Label = new Label();
		private var labelListaStudents:Label = new Label();
		
		private var labelCourses:Label = new Label();
		private var labelAddCourses:Label = new Label();
		private var labelListaCourses:Label = new Label();
		private var tool:Tool = new Tool();
		
		public function AdminPanel(p:SuperPanel){
			panel = p;
			labelStudents.x = 10;
			labelStudents.y = 27;
			labelStudents.width = panel.width-30;
			labelStudents.height = 30;
			labelStudents.text = "Studenti:";
			panel.addChild(labelStudents);
			
			labelAddStudents.x = 30;
			labelAddStudents.y = 40;
			labelAddStudents.width = panel.width-30;
			labelAddStudents.height = 30;
			labelAddStudents.htmlText = "<b>- Dodaj studenta</b>";
			panel.addChild(labelAddStudents);
			labelAddStudents.buttonMode = true;
			labelAddStudents.useHandCursor = true;
			labelAddStudents.mouseChildren = false;
			labelAddStudents.addEventListener(MouseEvent.CLICK, onClickAddStudent);
			
			labelListaStudents.x = 30;
			labelListaStudents.y = 55;
			labelListaStudents.width = panel.width-30;
			labelListaStudents.height = 30;
			labelListaStudents.htmlText = "<b>- Lista studenata</b>";
			panel.addChild(labelListaStudents);
			labelListaStudents.buttonMode = true;
			labelListaStudents.useHandCursor = true;
			labelListaStudents.mouseChildren = false;
			labelListaStudents.addEventListener(MouseEvent.CLICK, onClickListaStudents);

			labelCourses.x = 10;
			labelCourses.y = 77;
			labelCourses.width = panel.width-30;
			labelCourses.height = 30;
			labelCourses.text = "Kursevi:";
			panel.addChild(labelCourses);
			
			labelAddCourses.x = 30;
			labelAddCourses.y = 90;
			labelAddCourses.width = panel.width-30;
			labelAddCourses.height = 30;
			labelAddCourses.htmlText = "<b>- Dodaj kurs</b>";
			panel.addChild(labelAddCourses);
			labelAddCourses.buttonMode = true;
			labelAddCourses.useHandCursor = true;
			labelAddCourses.mouseChildren = false;
			labelAddCourses.addEventListener(MouseEvent.CLICK, onClickAddCourse);
			
			labelListaCourses.x = 30;
			labelListaCourses.y = 105;
			labelListaCourses.width = panel.width-30;
			labelListaCourses.height = 30;
			labelListaCourses.htmlText = "<b>- Lista kurseva</b>";
			panel.addChild(labelListaCourses);
			labelListaCourses.buttonMode = true;
			labelListaCourses.useHandCursor = true;
			labelListaCourses.mouseChildren = false;
			labelListaCourses.addEventListener(MouseEvent.CLICK, onClickListaCourses);
		}
		
		public function onClickAddStudent(e:MouseEvent):void{
			if(!panel.parentApplication.checkExist("DODAJ STUDENTA")){
				var s:SuperPanel;
				panel.parentApplication.panels.push(s = tool.createPanel("DODAJ STUDENTA", 0, 320, 195, 300, 150, true, false, "DodajStudenta"));
				panel.parentApplication.addChild(s);
				s.backButton.addEventListener(MouseEvent.CLICK, panel.parentApplication.taskbarButtonClicked);
				s.backButton.addEventListener(MouseEvent.RIGHT_CLICK, panel.parentApplication.taskbarButtonRightClicked);
				var dodaj:NewStudent = new NewStudent(s);
				s.canMaximize(false);
			}
		}
		
		public function onClickListaStudents(e:MouseEvent):void{
			if(!panel.parentApplication.checkExist("LISTA STUDENATA")){
				var s:SuperPanel;
				panel.parentApplication.panels.push(s = tool.createPanel("LISTA STUDENATA", 0, 500, 300, 100, 100, true, false, "ListaStudenata"));
				panel.parentApplication.addChild(s);
				s.backButton.addEventListener(MouseEvent.CLICK, panel.parentApplication.taskbarButtonClicked);
				s.backButton.addEventListener(MouseEvent.RIGHT_CLICK, panel.parentApplication.taskbarButtonRightClicked);
				var listaStudenata:StudentsList = new StudentsList(s);
			}
		}
		
		public function onClickAddCourse(e:MouseEvent):void{
			if(!panel.parentApplication.checkExist("DODAJ KURS")){
				var s:SuperPanel;
				panel.parentApplication.panels.push(s = tool.createPanel("DODAJ KURS", 0, 320, 195, 300, 150, true, false, "DodajKurs"));
				panel.parentApplication.addChild(s);
				s.backButton.addEventListener(MouseEvent.CLICK, panel.parentApplication.taskbarButtonClicked);
				s.backButton.addEventListener(MouseEvent.RIGHT_CLICK, panel.parentApplication.taskbarButtonRightClicked);
				var dodaj:NewCourse = new NewCourse(s);
				s.canMaximize(false);
			}
		}
		
		public function onClickListaCourses(e:MouseEvent):void{
			if(!panel.parentApplication.checkExist("LISTA KURSEVA")){
				var s:SuperPanel;
				panel.parentApplication.panels.push(s = tool.createPanel("LISTA KURSEVA", 0, 500, 300, 100, 100, true, false, "ListaKurseva"));
				panel.parentApplication.addChild(s);
				s.backButton.addEventListener(MouseEvent.CLICK, panel.parentApplication.taskbarButtonClicked);
				s.backButton.addEventListener(MouseEvent.RIGHT_CLICK, panel.parentApplication.taskbarButtonRightClicked);
				var listaStudenata:CoursesList = new CoursesList(s);
			}
		}
	}
}